Exploring Scalable Vector Graphics (SVG) for web development.
2025-07-31
SVG Basics
SVG allows for the creation of shapes, paths, and text that can be styled with CSS and manipulated with JavaScript. This makes SVG a powerful tool for creating interactive and dynamic graphics on the web.
SVG Path
- Capital letters in SVG path commands indicate absolute coordinates, while lowercase letters indicate relative coordinates.
M
: Move to a specific point (e.g.,M 10 10
moves to coordinates (10, 10)).L
: Draw a line to a specific point (e.g.,L 20 20
draws a line to coordinates (20, 20)).H
: Draw a horizontal line (e.g.,H 30
draws a horizontal line to x=30).V
: Draw a vertical line (e.g.,V 40
draws a vertical line to y=40).Z
: Closes the current path by drawing a line back to the starting point.
Curves
Cubic bezier curves
,Quadratic bezier curves
, andArc
commands are used to create complex shapes.C
: Cubic Bezier curve (e.g.,C x1 y1 x2 y2 x y
) defines a curve with two control points and an end point.-
S
: Smooth cubic Bezier curve (e.g.,S x2 y2 x y
) continues from the previous curve's end point. -
Q
: Quadratic Bezier curve (e.g.,Q x1 y1 x y
) defines a curve with one control point and an end point. T
: Smooth quadratic Bezier curve (e.g.,T x y
) continues from the previous curve's end point.